import { Big, BigState } from "../core/Big"
import Utils from "../GameUtils"
import { Config } from "../../Config"
import { Player } from "../core/Player"
import { BaseHandler } from "./BaseHandler"

export class SmallHandler extends BaseHandler{

    /** 小子出大 */
    smallBornBig(data:any,player:Player) {
        //行动力消耗
        this.handlerMgr.spendAction(player,Config.COST_BORN_BIG)
        //出大
        let startPoint = this.gameMgr.map_point.get(data.start)
        let endPoint = this.gameMgr.map_point.get(data.end)
        let small = startPoint.small
        let oldBig = endPoint.big
        if(oldBig != null) {
            this.handlerMgr.showToast(player,"出大失败")
            oldBig.deleteState(BigState.HIDE)
            this.gameMgr.sendBroadcast(Utils.getObj("play_effect",{"effect":"big_die","point_id":endPoint.id,"username":player.username}))
            return
        }
        let big = new Big()
        big.init(this.gameMgr,small.player,endPoint,small,null)
        this.gameMgr.sendBroadcast(Utils.getObj("born_big",{"big":big.toObj()}))

    }   

}